<template>
  <div>
    <!--    :model="ruleForm" 进行数据的绑定
             :rules="rules" 数据的校验
            ref="ruleForm" 获取数据通过点击事件或者按钮什么的
     -->
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="文章标题" prop="name">
        <el-input v-model="ruleForm.carouselmap.title"></el-input>
      </el-form-item>

      <el-form-item label="日期" required>
        <el-col :span="11">
          <el-form-item prop="date1">
            <el-date-picker
              type="date"
              placeholder="选择日期"
              v-model="ruleForm.carouselmap.date"
              style="width: 100%"
            ></el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>

      <el-form-item label="公众号链接" prop="desc">
        <el-input type="textarea" v-model="ruleForm.carouselmap.url"></el-input>
      </el-form-item>
    </el-form>
    <el-row>
      <el-button type="primary" @click="commitMsg">提交信息</el-button>
    </el-row>
  </div>
</template>
<script>
// import axios from 'axios';
// import carouselmap from "@/api/carouselmap.js";
export default {
  data() {
    return {
      ruleForm: {
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
        carouselmap: {
          title: "",
          date: "",
          url: "",
        },
      },
      rules: {
        title: [
          { required: true, message: "请输入活动名称", trigger: "blur" },
          { min: 3, max: 5, message: "长度在 3 到 5 个字符", trigger: "blur" },
        ],
        url: [{ required: true, message: "请选择活动区域", trigger: "change" }],
        date: [
          {
            type: "date",
            required: true,
            message: "请选择日期",
            trigger: "change",
          },
        ],
      },
    };
  },
  methods: {
    commitMsg() {
      this.$carouselmap({
        url: "/api/eventsweb/navigation/save",
        method: "POST",
        data: this.ruleForm.carouselmap,
      }).then((res) => {
        this.$confirm("是否添加信息, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.$message({
              type: "success",
              message: "恭喜你，成功添加!",
            });
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消添加",
            });
          });
      });
    },

  },
};
</script>